//
//  PositionQueue.m
//  midiApp
//
//  Created by Laurent Novac on 25.02.11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PositionQueue.h"
#import "Position.h"

@implementation PositionQueue
@synthesize queue;
-(id)init{
	self=[super init];
	if(self){
		queue=[[NSMutableArray alloc]init];
	}
	return self;
}

/*--------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------QUEUE OPERATIONS----------------------------------------------------------------------------------*/

-(void)pushToTail:(Position*) pos{
	[queue insertObject:pos atIndex:0]; //will add the object at first position
}
-(Position*)popFromHead{
	Position* p;
	p=[queue lastObject];//just get the head of the Queue
	return p;
}
-(void)emptyQueue{
	[queue removeAllObjects];
}
-(void)logQueue{//log the entire queue
	NSEnumerator* enumerator=[queue objectEnumerator];
	Position* pos;
	while ((pos=[enumerator nextObject])) {
		NSLog([NSString stringWithFormat:@"x: %.2f y: %.2f \n",[pos pos].x,[pos pos].y]);
	}

}

/*--------------------------------------------------------------------------------------------------------------------------------------------*/
/*------------------------------------------MEMORY MANAGEMENT---------------------------------------------------------------------------------*/

-(void)dealloc{
	[queue release];
	[super dealloc];
}
@end
